import vue from "@vitejs/plugin-vue2";
import { resolve } from "path";
import { defineConfig } from "vite";
import { nodeResolve } from "@rollup/plugin-node-resolve";

// 路径查找
const pathResolve = (dir: string): string => {
  return resolve(__dirname, dir);
};

export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          // 将'ai-'开头的标签视为自定义元素
          isCustomElement: (tag) => tag.includes("ai-"),
        },
      },
      jsx: true,
      babel: {
        plugins: [
          ["@babel/plugin-proposal-decorators", { legacy: true }],
          ["@babel/plugin-proposal-class-properties", { loose: true }],
        ],
      },
    }),
    nodeResolve(), // 解析 Lit 的裸模块导入
  ],
  resolve: {
    alias: {
      "@": pathResolve("src"),
      components: pathResolve("./src/components"),
      utils: pathResolve("./src/utils"),
      views: pathResolve("./src/views"),
    },
  },
});
